package com.eight.clientcourse.controller;

import com.eight.clientcourse.service.ClientCrouseService;
import com.eight.clientcourse.service.OrderService;
import com.eight.clientcourse.vo.CourseVo;
import com.eight.clientcourse.vo.GuanZhuVo;
import com.eight.common.pojo.*;
import com.eight.common.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: qy8-education1
 * @description:
 * @author: 张亚祥
 * @create: 2023-06-02 20:23
 **/
@RestController
@RequestMapping("core")
@Api("视频详情页")
public class OrderController {
    @Resource
    private ClientCrouseService clientCrouseService;
    @Resource
    private OrderService orderService;
    @PostMapping("video/queryAllVideoByCourseId/{id}")
    @ApiOperation(value = "根据课程id获取所有的章节的视频")
    public Result findVideo(@PathVariable String id){

        List<EduVideo> video = clientCrouseService.findVideo(id);
        return Result.success(video);
    }
    @PostMapping("course/queryAllById/{id}/{mobile}")
    @ApiOperation(value = "根据手机号查询该视频信息是否该讲师发布的")
    public Result findTeacherByMobile(@PathVariable String id ,@PathVariable String mobile){
        List<EduCourse> teacherByMobile = clientCrouseService.findTeacherByMobile(id, mobile);

        if(teacherByMobile!=null){
            return Result.success(teacherByMobile);
        }else {
            return Result.fail();
        }


    }
    @PostMapping("order/getOrderStatus/{cid}/{memberId}")
    @ApiOperation(value = "根据课程id和会员id查询支付状态")
    public Result getOrderStatus(@PathVariable String cid,@PathVariable String memberId){

        List<TOrder> orderByMemberByCourse = orderService.findOrderByMemberByCourse(cid, memberId);
        return Result.success(orderByMemberByCourse);
    }

    @PostMapping("shoucangTeacher/findAttentionTeacher/{teacherId}/{memberId}")
    @ApiOperation(value = "进入页面渲染是否已经关注")
    public Result findAttentionTeacher(@PathVariable String teacherId,@PathVariable String memberId){

        EduTeacher eduTeacher = orderService.findTeacherStatus(teacherId,memberId);
        return Result.success(eduTeacher);
    }
    @PostMapping("shoucangTeacher/addAttentionTeacher")
    @ApiOperation(value = "关注讲师")
    public Result shouCangTeacher(@RequestBody TbShoucangTeacher tbShoucangTeacher){
        int i = orderService.insertShouCangTercher(tbShoucangTeacher);
        return Result.success();
    }
    @PostMapping("chapter/findChapterById/{id}")
    @ApiOperation(value = "根据课程id获取所有的章节的视频")
    public Result findChapterById(@PathVariable String id){
        List<EduVideo> chapterById = orderService.findChapterById(id);
        return Result.success(chapterById);
    }
    @PostMapping("shoucangTeacher/deleteAttentionTeacher")
    @ApiOperation(value = "取消关注讲师")
    public Result deleteAttentionTeacher(@RequestBody GuanZhuVo guanZhuVo){
        int i = orderService.deleteAttentionTeacher(guanZhuVo);
        return Result.success();
    }
}
